package com.chj.service.impl;

import com.chj.channel.DefaultProcess;
import com.chj.service.IMessageProvider;
import com.chj.vo.Product;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;

/**
 * 消息方法方法
 */
//@EnableBinding(Source.class)
@EnableBinding(DefaultProcess.class)
public class MessageProviderImpl implements IMessageProvider {
    @Resource
    @Qualifier("hankin_output") //TODO 用于查询注定名称注解对应 @Output(DefaultProcess.OUTPUT)
    private MessageChannel output;  // 消息的发送管道
    @Override
    public void send(Product product) {
        output.send(MessageBuilder.withPayload(product).build());
    }
}
